const request = require("request");
class Ut {/**
    * promise化request
    * @param {object} opts 
    * @return {Promise<[]>}
    */
    static promiseReq(opts = {}) {
        return new Promise((resolve, reject) => {
            request(opts, (e, r, d) => {
                if (e) {
                    return reject(e);
                }
                if (r.statusCode != 200) {
                    return reject(`back statusCode：${r.statusCode}`);
                }
                return resolve(d);
            });
        })
    };
    static translate(pos) {
        pos = { x: (pos.x) * 30, y: (pos.y * (-1)) * 30 }
        return pos
    };
    static getID(length){
        return Number(Math.random().toString().substr(3,length) + Date.now()).toString(36);
    }
}
module.exports = Ut;